package test1;

import java.io.*;
import java.util.List;

import org.apache.commons.io.FileUtils;

public class StripDebug {
	public static void main(String[] args) throws IOException{
		File file = new File("src/test1/Demo.java.bak");
		InputStream in = new FileInputStream(file);
		InputStreamReader reader = new InputStreamReader(in);
		
		int data;
		StringBuffer sb = new StringBuffer();
		List lines = FileUtils.readLines(file,"UTF-8");
		for(int i=0 ; i<lines.size() ; i++){
			String a = lines.get(i).toString();
			//System.out.println(a.indexOf("/**dbg**/") > 0);
			if(a.indexOf("/**dbg**/") < 1){
				System.out.println(i+1 +". "+lines.get(i));
				sb.append(lines.get(i).toString() + "\r\n");
			}
		}
		System.out.println(sb.toString());
		
		File outfile = new File("src/test1/Demo.java");
		FileOutputStream outstream = new FileOutputStream(outfile);
		
		outstream.write(sb.toString().getBytes());
		outstream.close();
	}
	
}
